import request from '@/utils/request';
import {download, toFormData} from '@/utils/common';


/**
 * 获取学生的基本信息
 * @returns {Promise<any>}
 */
export async function selectStudentBaseInfo() {
  const res = await request.get('/student/recommend/base');
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 查询学生推荐表信息
 * @returns {Promise<any>}
 */
export async function selectStudentRecommendInfo() {
  const res = await request.get('/student/recommend/recommend');
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 查询学生确认信息
 * @returns {Promise<any>}
 */
export async function selectStudentCheckInfo() {
  const res = await request.get('/student/recommend/checkInfo');
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/**
 * 获取学生生源地
 */
export async function getSource() {
  const res = await request.get('/student/recommend/source');
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 提交学生生源地
 * @param data
 * @returns {Promise<any>}
 */
export async function submitSource(data) {
  const res = await request.put('/student/recommend/source/' + data);
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 提交学生基础信息
 * @param data
 * @returns {Promise<any>}
 */
export async function submitBaseInfo(data) {
  const res = await request.put('/student/recommend/base/', data);
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 提交学生推荐表信息
 * @param data
 * @returns {Promise<any>}
 */
export async function submitRecommendInfo(data) {
  const res = await request.put('/student/recommend/recommend/', data);
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}


/**
 * 确认学生的生源地是否在数据库中
 * @returns {Promise<any>}
 */
export async function confirmSource() {
  const res = await request.get('/system/admin/student/list');
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

/**
 * 学生确认推荐信息
 * @returns {Promise<any>}
 */
export async function confirmInfo() {
  const res = await request.put('/student/recommend/confirmInfo');
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}





